package com.train.order.bo;

import cn.hutool.json.JSONUtil;
import com.train.order.dto.confirm.ConfirmOrderTicketDTO;
import com.train.order.enums.impl.ConfirmOrderStatusEnums;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDate;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ConfirmOrderTicketBO {

    /**
     * 新增以后的订单确认id
     */
    private Long confirmOrderId;

    /**
     * 会员id
     */
    private Long memberId;

    /**
     * 车次日期
     */
    private LocalDate date;

    /**
     * 车次
     */
    private String trainCode;

    /**
     * 出发站
     */
    private String start;

    /**
     * 到达站
     */
    private String end;

    /**
     * 余票ID
     */
    private Long dailyTrainTicketId;

    /**
     * 票信息,json字符串
     */
    private String tickets;

    /**
     * 订单状态
     */
    private String status;

    /**
     * 转json,设置票信息
     * @param passengerTickets
     */
    public void setTickets(List<ConfirmOrderTicketDTO.PassengerTicket> passengerTickets) {
        this.tickets = JSONUtil.toJsonStr(passengerTickets);
    }

    public void setDailyTrainTicket(Long id) {
        this.dailyTrainTicketId = id;
    }

    public void initStatus() {
        this.status = ConfirmOrderStatusEnums.INIT.getCode();
    }
}
